package com.nuanshui.heatedloan.msgcenter.apppush;

import com.nuanshui.heatedloan.msgcenter.apppush.bean.Invoker;
import com.nuanshui.heatedloan.msgcenter.apppush.filter.AppPushFilterContainer;
import com.nuanshui.heatedloan.msgcenter.model.AppPushMessage;

/**
 * 
 * @param 
 * @author guohao
 * @date 2017年2月10日 下午4:32:48
 * @since $
 */
public class AppPushFacade {
	
	//推送的过滤器链容器
	private  AppPushFilterContainer filterContainer = new AppPushFilterContainer();
	
	private volatile Invoker invoker = null;

	public AppPushFilterContainer getWrapper() {
		return filterContainer;
	}
	
	/**
	 * 推送方法
	 * @param @param appPushMessage
	 * @author guohao
	 * @date 2017年2月10日 下午4:47:48
	 * @since $
	 */	
	public void  push(AppPushMessage appPushMessage) {
		if(invoker == null) {
			synchronized (AppPushFacade.class) {
				if(invoker == null) {
					AppPushExecute appPushExecute = new AppPushExecute();
					invoker =  filterContainer.buildFilterChain(appPushExecute);
				}				
			}
		}
		invoker.doInvoker(appPushMessage);	
	}

}
